package main

import (
	"crypto/sha1"
	"fmt"
	"io/ioutil"
	"regexp"
)

const hostsDIR = `C:\Windows\System32\drivers\etc\hosts`

func getDate(b []byte) string {
	reg := regexp.MustCompile(`Last updated: ([0-9\-]+)`)
	if reg.Match(b) {
		datab := reg.FindSubmatch(b)[1]
		return string(datab)
	}
	return ""
}

func getGitSha1(b []byte) string {
	tmp := []byte(fmt.Sprintf("blob %d\x00%s", len(b), b))
	return fmt.Sprintf("%x", sha1.Sum(tmp))
}

func main() {
	b, _ := ioutil.ReadFile(hostsDIR)
	data := getDate(b)
	if data != "" {
		fmt.Println(getGitSha1(b))
	}
}
